{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np # linear algebra\n",
    "import pandas as pd # data processing, CSV file I/O\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "#color = sns.color_palette()\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011-01-02</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011-01-03</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011-01-05</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011-01-01       1   0     1        0        6           0   \n",
       "1        2  2011-01-02       1   0     1        0        0           0   \n",
       "2        3  2011-01-03       1   0     1        0        1           1   \n",
       "3        4  2011-01-04       1   0     1        0        2           1   \n",
       "4        5  2011-01-05       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# path to where the data lies\n",
    "#dpath = './data/'\n",
    "data = pd.read_csv(\"day.csv\")\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.1 显示数据基本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(731, 16)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2 数据探索"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "详情请见文件：bike_data_search.ipynb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.3 数据准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 从原始数据中分离输入特征x和输出y，去除无用特征\n",
    "# mnth, atemp通过数据探索，发现分别和season，temp强相关，二者保留一个\n",
    "y = data['cnt'].values\n",
    "X = data.drop(['cnt','instant','dteday','casual','registered','mnth','atemp'], axis = 1)\n",
    "\n",
    "# 数据筛选，2011年数据作为训练数据，2012年数据作为测试数据\n",
    "X_train = X[X.yr==0]\n",
    "X_test = X[X.yr==1]\n",
    "y_train = data[data.yr==0]['cnt'].values\n",
    "y_test = data[data.yr==1]['cnt'].values\n",
    "\n",
    "# 训练集，数据集区分后，yr为无用特征\n",
    "X_train = X_train.drop(['yr'], axis = 1)\n",
    "X_test = X_test.drop(['yr'], axis = 1)\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X_train.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(365, 8)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#发现各特征差异较大，需要进行数据标准化预处理\n",
    "#标准化的目的在于避免原始特征值差异过大，导致训练得到的参数权重不归一，无法比较各特征的重要性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/karen/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 数据归一化\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "\n",
    "# 分别初始化对特征和目标值的归一化，标准化器\n",
    "ss_X = MinMaxScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征进行归一化处理\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.fit_transform(X_test)\n",
    "\n",
    "#对y做标准化不是必须\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.fit_transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3 确定模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.1 尝试缺省参数的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[2.64627277464]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.806406103721]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[0.10632898224]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.0157666662646]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.218801933457]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[-0.388828037348]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[-0.781070780969]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[-0.790465134032]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                coef     columns\n",
       "5    [2.64627277464]        temp\n",
       "0   [0.806406103721]      season\n",
       "2    [0.10632898224]     weekday\n",
       "3  [0.0157666662646]  workingday\n",
       "1  [-0.218801933457]     holiday\n",
       "6  [-0.388828037348]         hum\n",
       "7  [-0.781070780969]   windspeed\n",
       "4  [-0.790465134032]  weathersit"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1.1 模型评价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.675918886778\n",
      "The r2 score of LinearRegression on train is 0.758512965677\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print('The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print('The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeoAAAFsCAYAAAADhPr/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHlVJREFUeJzt3XuUXGWZ7/HvQ9ISh0AQ6EAgZgIK\nyj3BJibDgNF4YQQJrnEGPQhhcYmizHJ0dBQ5SsvoqAdGlxyjZ+INEJTbyMConIETyUQ4CpMw4WbQ\nRCXHhEwIcbgE5ZLmOX/UTux0utOV7qrut7u+n7VqVdXeu/Z+3trp/Orde9dbkZlIkqQy7TLcBUiS\npL4Z1JIkFcygliSpYAa1JEkFM6glSSqYQS1JUsEMarW8iHgoImYPdx3DKSLeHhG/iYhNETF9CLe7\nKSIO6mPeWRFxZ4O280hEvLER65KGmkGtUa23/6B7BkBmHp6Zi/tZz9SIyIgY26RSh9tlwAWZOT4z\n/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+GRFxBLUfnn81tQH39wI+2ttrI2J+RCyNiKUbNmwYcKGS\nNJo9++yz7L333ob0KBIR7L333oM+SrJTV31n5hPAYuDEzFxX/Tbtc9R+5WZGH69ZmJkdmdnR3l7X\nV8YkqSUZ0qNPI/ZpPVd9t0fEntXjlwJvBB6OiEnVtABOBR4cdDWSJGkb9ZyjngRcWZ2n3gW4PjO/\nHxE/ioh2IIDlwHubWKcktZTOzqFf35gxYzjyyCPZvHkzBx54IN/+9rfZc889d3pb5557Lh/60Ic4\n7LDDtpl+xRVXsHTpUr785S/v9DoBxo8fz6ZNm/pfEJg9ezaXXXYZHR0dW6ctXbqUq666issvv3xA\n2x8u9Vz1fT8wvZfpb2hKRZKkYfHSl76U5cuXAzBv3jwWLFjARRddtNPr+frXv97o0hqio6Njm+Bu\nhq6uLsaMGdPQdToymSRpO7NmzWLt2rVbn1966aUce+yxHHXUUVx88cUAPPPMM5x00kkcffTRHHHE\nEVx33XVArTe7Zbjob33rWxxyyCG87nWv46677tq6vrPOOosbb/zDMBzjx48HYNOmTcyZM4djjjmG\nI488kptvvnm72tatW8cJJ5zAtGnTOOKII/jxj39cV5sWL17MySefDEBnZydnn302s2fP5qCDDtqm\nl3311VczY8YMpk2bxnve8x66uroAOP/88+no6ODwww/f+h5AbXjsSy65hD/90z/lhhtuqKuWnTGk\nY31LksrX1dXFokWLOOeccwC47bbbWLlyJffccw+ZySmnnMKSJUvYsGED+++/Pz/4wQ8AePLJJ7dZ\nz7p167j44otZtmwZEyZM4PWvfz3Tp293gHYb48aN46abbmKPPfbg8ccfZ+bMmZxyyinbXJT1ne98\nh7e85S1cdNFFdHV18bvf/W5A7Xz44Ye54447ePrpp3nVq17F+eefz6pVq7juuuu46667aGtr433v\nex/XXHMNZ555Jp/5zGfYa6+96OrqYs6cOdx///0cddRRW+u+8847B1RHfwxqSRIAv//975k2bRqP\nPPIIr3nNa3jTm94E1IL6tttu2xqymzZtYuXKlRx//PF8+MMf5qMf/Sgnn3wyxx9//Dbru/vuu5k9\nezZbvvFz2mmn8Ytf/GKHNWQmH//4x1myZAm77LILa9euZf369ey3335blzn22GM5++yzeeGFFzj1\n1FOZNm1gI1ifdNJJ7Lrrruy6665MnDiR9evXs2jRIpYtW8axxx679T2ZOHEiANdffz0LFy5k8+bN\nrFu3jp/97Gdbg/q0004bUA318NC3JAn4wznq1atX8/zzz7NgwQKgFp4XXnghy5cvZ/ny5axatYpz\nzjmHQw45hGXLlnHkkUdy4YUXcskll2y3zr6+njR27FhefPHFret//vnnAbjmmmvYsGEDy5YtY/ny\n5ey7777bfQ/5hBNOYMmSJRxwwAGcccYZXHXVVQNq76677rr18ZgxY9i8eTOZybx587a29ec//zmd\nnZ38+te/5rLLLmPRokXcf//9nHTSSdvUtdtuuw2ohnrYo5Y0ZOq9krnRVzxr50yYMIHLL7+cuXPn\ncv755/OWt7yFT3ziE5x++umMHz+etWvX0tbWxubNm9lrr71497vfzfjx47niiiu2Wc9rX/taPvCB\nD7Bx40b22GMPbrjhBo4++migdl532bJl/OVf/iU333wzL7zwAlA7fD5x4kTa2tq44447WL16+1+D\nXL16NQcccADnnXcezzzzDPfeey9nnnlmQ9o+Z84c5s6dywc/+EEmTpzIb3/7W55++mmeeuopdttt\nNyZMmMD69eu59dZbmT17dkO22R+DWpIKNNwfVqZPn87RRx/NtddeyxlnnMGKFSuYNWsWULvw6+qr\nr2bVqlV85CMfYZdddqGtrY2vfvWr26xj0qRJdHZ2MmvWLCZNmsQxxxyz9cKs8847j7lz5zJjxgzm\nzJmztUd6+umn87a3vY2Ojg6mTZvGq1/96u1qW7x4MZdeeiltbW2MHz++zx71SSedtHWM7VmzZvH+\n97+/33YfdthhfPrTn+bNb34zL774Im1tbSxYsICZM2cyffp0Dj/8cA466CCOO+64+t/MQYrab24M\njY6OjtxyJaCk1mOPum8rVqzg0EMPHe4y1AS97duIWJaZdX1XzHPUkiQVzKCWJKlgBrUkFWIoT0Vq\naDRinxrUklSAcePGsXHjRsN6FNnye9Tjxo0b1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sZuT79G7VqdVjGi/8YHIzOf6vb4hxHxlYjYJzN3+EMlw3XV94nAR4FTMvN3fSzW\nskOURsRuEbH7lsfULr7r9SrCUWg07/dbgHnV43nAdkcYIuJlEbFr9Xgf4DjgZ0NWYePUsx+7vx/v\nAH7Ux4f2kabftvc4J3sKsGII6xtutwBnVld/zwSe3HJKaLSLiP22XIcRETOoZfDGHb+KYbvqexW1\ncxTLq9uWKz/3B37Ybbm3Ar+g1pu4aDhqbULb307tE+VzwHrgX3u2ndrVovdVt4daqe2jdb9X7dob\nWASsrO73qqZ3AF+vHv8J8EC17x8AzhnuugfR3u32I3AJtQ/oAOOAG6r/D+4BDhrumoew7Z+t/rbv\nA+4AXj3cNTew7d8F1gEvVH/v5wDvBd5bzQ9gQfXePMAOvv0y0m51tP2Cbvv9p8Cf1LNehxCVJKlg\nJVz1LUmS+mBQS5JUMINakqSCGdSSJBXMoJYkqWAGtSRJBTOoJUkq2P8HI+E0q8p5ZHMAAAAASUVO\nRK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a0867a3c8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvd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AAAA\nAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a0867a860>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True counts')\n",
    "plt.ylabel('Predicted counts')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/karen/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:578: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.80783094, -0.2221954 ,  0.10331093,  0.01409309, -0.77659745,\n",
       "        2.64133536, -0.42605511, -0.79706072])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性模型，随机梯度下降优化模型参数\n",
    "# 随机梯度下降一般在大数据集上应用，其实本项目不适合用\n",
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "# 使用默认配置初始化线\n",
    "sgdr = SGDRegressor(max_iter=1000)\n",
    "\n",
    "# 训练：参数估计\n",
    "sgdr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "#sgdr_y_predict = sgdr.predict(X_test)\n",
    "\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of SGDRegressor on test is 0.676092443636\n",
      "The value of default measurement of SGDRegressor on train is 0.758489929217\n"
     ]
    }
   ],
   "source": [
    "# 使用SGDRegressor模型自带的评估模块(评价准则为r2_score)，并输出评估结果\n",
    "print('The value of default measurement of SGDRegressor on test is', sgdr.score(X_test, y_test))\n",
    "print('The value of default measurement of SGDRegressor on train is', sgdr.score(X_train, y_train))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.2 正则化的线性回归（L2正则 --> 岭回归）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.676080126595\n",
      "The r2 score of RidgeCV on train is 0.758500179447\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [0.001, 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print('The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print('The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl0XOWd5vHvI9nyDja2vNvYBGPA\nGwaFdBqSQMJiEmOWbCTdM6S705zMiSfpTm8wmSFnYHImJ5lJ90yG7g7dzek+pztNL4FQckxYkhAI\nCYmF7fIGBtkELJdkywvebVnSb/6oUihkWSVjXV2p6vmc40Pde9+37q9IqMf3fW/dVxGBmZlZb6rS\nLsDMzAY/h4WZmZXksDAzs5IcFmZmVpLDwszMSnJYmJlZSQ4LMzMryWFhZmYlOSzMzKykYWkX0F8m\nTZoUc+bMSbsMM7Mh5cUXX9wTEbWl2pVNWMyZM4eGhoa0yzAzG1Ikvd6Xdh6GMjOzkhwWZmZWksPC\nzMxKcliYmVlJDgszMyvJYWFmZiUlGhaSlknaKqlR0t2nafMJSVskbZb0naL9HZLWF/5kkqzTzMx6\nl9jvLCRVAw8A1wNNwBpJmYjYUtRmHnAPcFVE7Jc0uegtjkXEZUnVZ2ZWDh5Z20R7Z/CJulmJnifJ\nK4srgcaI2B4RbcDDwC3d2vw+8EBE7AeIiN0J1mNmVlYigm/9qJHH1u9M/FxJhsUMYEfRdlNhX7GL\ngIskPS/pBUnLio6NlNRQ2H9rgnWamQ1Jm3Ye5LU9R1ixZHri50rycR/qYV/0cP55wDXATOA5SQsj\n4k1gdkTkJF0A/EjSxojY9rYTSHcBdwHMnj27v+s3MxvUMtmdDK8WyxZMS/xcSV5ZNAHFg2gzgVwP\nbR6LiJMR8RqwlXx4EBG5wj+3A88AS7ufICIejIi6iKirrS35HCwzs7LR2Rms2tDMBy6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lib.figure.Figure at 0x1a11de0470>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.1\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[2.64627277464]</td>\n",
       "      <td>[2.63201775383]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.806406103721]</td>\n",
       "      <td>[0.808108125841]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[0.10632898224]</td>\n",
       "      <td>[0.105953485772]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.0157666662646]</td>\n",
       "      <td>[0.016318751526]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.218801933457]</td>\n",
       "      <td>[-0.216342952288]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[-0.388828037348]</td>\n",
       "      <td>[-0.376771015863]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[-0.781070780969]</td>\n",
       "      <td>[-0.771026109166]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[-0.790465134032]</td>\n",
       "      <td>[-0.793394958009]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             coef_lr         coef_ridge     columns\n",
       "5    [2.64627277464]    [2.63201775383]        temp\n",
       "0   [0.806406103721]   [0.808108125841]      season\n",
       "2    [0.10632898224]   [0.105953485772]     weekday\n",
       "3  [0.0157666662646]   [0.016318751526]  workingday\n",
       "1  [-0.218801933457]  [-0.216342952288]     holiday\n",
       "6  [-0.388828037348]  [-0.376771015863]         hum\n",
       "7  [-0.781070780969]  [-0.771026109166]   windspeed\n",
       "4  [-0.790465134032]  [-0.793394958009]  weathersit"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.3 正则化的线性回归（L1正则 --> Lasso）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.653598292723\n",
      "The r2 score of LassoCV on train is 0.748113832682\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/karen/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "lasso = LassoCV(alphas=alphas)  \n",
    "# lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdG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ux8AcPc2M3uY5HVwE6MZKNjF9TcqBBkN2lIQEZE+mmgWEZE+KgUREemjUhARkT4qBRER6aNSEBGR\nPioFERHp8/8BA6351oIm0w0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a12289b70>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.01\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2.481856</td>\n",
       "      <td>[2.64627277464]</td>\n",
       "      <td>[2.63201775383]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.780145</td>\n",
       "      <td>[0.806406103721]</td>\n",
       "      <td>[0.808108125841]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.019893</td>\n",
       "      <td>[0.10632898224]</td>\n",
       "      <td>[0.105953485772]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.0157666662646]</td>\n",
       "      <td>[0.016318751526]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-0.218801933457]</td>\n",
       "      <td>[-0.216342952288]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-0.388828037348]</td>\n",
       "      <td>[-0.376771015863]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.327076</td>\n",
       "      <td>[-0.781070780969]</td>\n",
       "      <td>[-0.771026109166]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.819273</td>\n",
       "      <td>[-0.790465134032]</td>\n",
       "      <td>[-0.793394958009]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   coef_lasso            coef_lr         coef_ridge     columns\n",
       "5    2.481856    [2.64627277464]    [2.63201775383]        temp\n",
       "0    0.780145   [0.806406103721]   [0.808108125841]      season\n",
       "2    0.019893    [0.10632898224]   [0.105953485772]     weekday\n",
       "3    0.000000  [0.0157666662646]   [0.016318751526]  workingday\n",
       "1   -0.000000  [-0.218801933457]  [-0.216342952288]     holiday\n",
       "6   -0.000000  [-0.388828037348]  [-0.376771015863]         hum\n",
       "7   -0.327076  [-0.781070780969]  [-0.771026109166]   windspeed\n",
       "4   -0.819273  [-0.790465134032]  [-0.793394958009]  weathersit"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHxhJREFUeJzt3Wl0VPed5vHvTxsSqwCJRSA2G7wb\nGwvZjtfEWYjbMbHjDejO0kk8OTPp0z0z3RPnZE48k34xk8lMn+kl6Yw7k+PONMLYseMtdhzHS0jc\nQUKAwSzGxsQUQgIJA2KThJbfvKgrpRCSKBld3aq6z+ccHUpV/1I9usB96t5/3XvN3REREQHIizqA\niIhkDpWCiIj0USmIiEgflYKIiPRRKYiISB+VgoiI9FEpiIhIH5WCiIj0USmIiEifgqgDDFdZWZnP\nmzcv6hgiIlll48aNh9y9/Fzjsq4U5s2bR319fdQxRESyipntTWecdh+JiEgflYKIiPRRKYiISB+V\ngoiI9FEpiIhIH5WCiIj0USmIiEifrDtOQSRTtJ3uprG1jcajbTQdbaeptZ3unp6oY0kOq5o3hZsX\nnfP4s/OiUhAZQHePc+hEB/uPJlf6ya929h9to6k1efvwydNnPc8sgrASG1+75QKVgkgYjrd30ni0\nncajbWes6HtL4EBrO109fsZzJowpoKK0hIrSYhbPLqWitIRZpSVUlJYwc1IxMyYVU5ivPbKS3VQK\nknM6u3s40JrcndO70u99t9/UmlzxH2/vOuM5BXnGjEn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AbWJQyvpnk\n6UZEQqVSkDga7II3Q10Ip43kOY0ws/nAXwJL3f2ImT3a+9g5pJ5TpiP4s5s//D/89yTPObWY5FZ8\ne8r44iCDSKi0+0jiaB1wv5nlB/v5byZ54rrfkrwITZ6ZTSd5OcZeO4ELg9sTgZNAazDu04O8Th7J\ns6QCrAx+/lAmAU3BlsqfkLzEZq9FZMZZciXHaUtB4uhnJOcLtpB89/6f3P2AmT0J3EZy5fsOyatd\ntQbP+TnJkviVu28xs80kz6C5B3hjkNc5CVxmZhuDn3P/OXL9AHjSzO4leRbTkymPfTTIIBIqnSVV\nJIWZjffklbamktx6uCEojBKSK+obgrmIdH7WCXcfP0K51gHL3f3ISPw8kcFoS0HkTM+bWSlQBPy1\nux8AcPc2M3uY5HVwE6MZKNjF9TcqBBkN2lIQEZE+mmgWEZE+KgUREemjUhARkT4qBRER6aNSEBGR\nPioFERHp8/8BA6351oIm0w0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a12176f28>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.01\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 测试集上各个模型分数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.67591888677767664"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# OLS分数\n",
    "lr.score(X_test,y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.6760801265949421"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 岭回归分数\n",
    "ridge.score(X_test,y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.65359829272255299"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# lasso分数\n",
    "lasso.score(X_test,y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
